<?php

class SearchPanel extends PageElement
{
	
	public function getHTML()
	{
		// Search options
		
		// From Resource Table
		// 	- 	Title - text
		//	- 	Description - text
		//	- 	Keywords - text	
		//	- 	Type - one or more of one
		//	- 	Category - one or more of many
		
		// From Composers
		//	-	Surname - text
		//	-	FirstName - text
		//	-	Secondnames - text
		//	-	DOB - date
		//	-	DOD - date
		//	-	Biography - text
		
		// From Files
		//	-	FileName - text
		//	-	FileType - one or more of several (MIME Type??)
		
		// From Links
		//	-	URL - text ??
		
		// From Repertoire Items
		//	-	Composer - one or more of many
		//	-	Title - Text
		//	-	Voices - Text ?????
		//	-	Usage - one or more of many
		//	-	Text - text
		//	-	Translation - text
		
		//FIRST SIMPLE VERSION 
		//
		// do simple words in all resource text fields
		// select one or more of Type
		// select one of more of Category
		$html = "";
		
		$html .= "<table><tr>\n";
		$html .= "<td><b>Search Resource Types</b><br><br>";
		
		$types = new Enumeration($this->getParentPage()->getDatabase(),"ResourceTypes");
		$typeInput = new MultiSelectEnumeration($types->getArray());
		$typeInput->setSize(count($types->getArray()));
		$typeInput->setName('SearchTypes');
		if(isset($_POST['SearchTypes']))
			$typeInput->setSelected($_POST['SearchTypes']);
		$html .= $typeInput->getHTML();
		
		$html .= "</td>\n<td><b>Search Categorys</b><br><br>";
		
		$categories = new Enumeration($this->getParentPage()->getDatabase(),"ResourceCategoryNames");
		$categoryInput = new MultiSelectEnumeration($categories->getArray());
		$categoryInput->setSize(count($categories->getArray()));
		$categoryInput->setName("SearchCategorys");
		if(isset($_POST['SearchCategorys']))
			$categoryInput->setSelected($_POST['SearchCategorys']);
		$html .= $categoryInput->getHTML();
		
		$html .= "</td>\n<td><b>Search Text</b><br><br>";
		$input = new TextArea();
		$input->setName("SearchText");
		if(isset($_POST['SearchText']))
			$input->setText($_POST['SearchText']);
		$html .= $input->getHTML();
		
		$html .= "</td>\n</tr>\n<tr>\n<td>";
		
		$refreshButton = new Button();
		$refreshButton->setOnClick("document.getElementById('PageForm').submit();");
		$refreshButton->setName("SearchRefresh");
		$refreshButton->setValue("Refresh List");
		$html .= $refreshButton->getHTML();
		
		
		$html .= "</td>\n</tr></table>\n";
		
		return $html;
	}
	
}

?>